﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AgileLogistics.Comm
{
    public class BillNoGenerate
    {
        

        public static string GenerateShenQingNO()
        {
            //查询当前最大ID
            Model.DBContext dBContext = new Model.DBContext();
            var MaxId = dBContext.DB.Queryable<Model.MaxId>().First();
            //MaxId.ShenqingId += 1;
            //dBContext.DB.Updateable<Model.MaxId>(MaxId).ExecuteCommand();
            //规则
            string NO = "SQ" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0') + (MaxId.ShenqingId + 1).ToString().PadLeft(5, '0');
            return NO;
        }



        public static void ShenqingNoAdd   ()
       {
            Model.DBContext dBContext = new Model.DBContext();
            var MaxId = dBContext.DB.Queryable<Model.MaxId>().First();

            MaxId.ShenqingId += 1;
            dBContext.DB.Updateable<Model.MaxId>(MaxId).ExecuteCommand();
        }

        public static void WeixiuNoAdd()
        {
            Model.DBContext dBContext = new Model.DBContext();
            var MaxId = dBContext.DB.Queryable<Model.MaxId>().First();
            MaxId.WeixiuId += 1;
            dBContext.DB.Updateable<Model.MaxId>(MaxId).ExecuteCommand();
        }


        public static string GenerateWeiXiuNO()
        {
            //查询当前最大ID
            Model.DBContext dBContext = new Model.DBContext();

            var MaxId = dBContext.DB.Queryable<Model.MaxId>().First();
             


            //规则
            string NO = "WX" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0') + (MaxId.WeixiuId + 1).ToString().PadLeft(5, '0');
            return NO;
        }
    }
}
